package com.archgeek.java.conc.thread;

import org.junit.Test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;

/**
 * @author pizhihui
 * @date 2024-03-19
 */
public class CompletetableFutureDemo2 {

    @Test
    public void test1() throws ExecutionException, InterruptedException {

        CompletableFuture<Void> cf1 = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName());
        });

        CompletableFuture<Void> cf2 = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName());
        }, Executors.newSingleThreadExecutor());

        cf1.get();
        cf2.get();

    }


}
